package com.gamex.findit.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gamex.findit.dao.MemberItemMapper;
import com.gamex.findit.model.MemberItem;
import com.gamex.findit.service.MemberItemService;

/**
 * 회원 아이템 서비스
 * @author james
 *
 */
@Service
public class MemberItemServiceImpl implements MemberItemService{
	
	private static final Logger logger = LoggerFactory.getLogger(MemberItemServiceImpl.class);

	@Autowired MemberItemMapper memberItemMapper;
	
	@Override
	public List<MemberItem> getMemberItem(MemberItem memberItem) throws Exception{
		List<MemberItem> result = null;
		try {
			result = memberItemMapper.selectMemberItem(memberItem);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

	@Override
	public int getMemberItemCount(MemberItem memberItem) throws Exception{
		int count = 0;
		try {
			count = memberItemMapper.selectMemberItemCount(memberItem);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return count;
	}

	@Override
	public MemberItem getMemberItemView(int itemNo, String userId) throws Exception{
		MemberItem result = null;
		try {
			result = memberItemMapper.selectMemberItemView(itemNo, userId);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}
	
	@Override
	public MemberItem checkMemberItem(int itemNo, String userId) throws Exception{
		MemberItem result = null;
		try {
			result = memberItemMapper.checkMemberItem(itemNo, userId);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

	@Override
	public int insertMemberItem(MemberItem memberItem) throws Exception{
		int result = 0;
		try {
			result = memberItemMapper.insertMemberItem(memberItem);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		return result;
	}

	@Override
	public void updateMemberItem(MemberItem memberItem) throws Exception{
		try {
			memberItemMapper.updateMemberItem(memberItem);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		
	}

	@Override
	public void deleteMemberItem(int itemSeq) throws Exception{
		try {
			memberItemMapper.deleteMemberItem(itemSeq);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		
	}

	@Override
	public void deleteMemberItemByItemNo(int itemNo) throws Exception {
		try {
			memberItemMapper.deleteMemberItemByItemNo(itemNo);
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw e;
		}
		
	}

}
